<template>
  <div class="container">
    <div class="showCont" v-if="!showTimeOut && showCont">
      <div class="stepTitle">
        <div class="sendBook" v-if="detailInfo.is_bidder == 2">
          <img src="/img/sendBook.png" />
        </div>
        <div class="stepName">
          <div>{{ detailInfo.position_name }}</div>
          <div class="quckTag" v-if="detailInfo.position_type == 2">急聘</div>
        </div>
        <div class="moneyNum">
          ¥{{ parseInt(detailInfo.price_start) }}-{{
            parseInt(detailInfo.price_end)
          }}k/月
        </div>
      </div>
      <div class="tagCont">
        <div class="tagItem">{{ detailInfo.experience }}</div>
        <div class="userNum_">·</div>
        <div class="tagItem">{{ detailInfo.education }}</div>
      </div>
      <div class="walfCont">
        <div class="walfItem" v-if="detailInfo.salary_month > 12">
          {{ detailInfo.salary_month }} 薪
        </div>
        <div class="walfItem" :key="index" v-for="(item, index) in walfArr">
          {{ item }}
        </div>
      </div>
      <div class="stepTitle hasTop">
        <div class="stepName">工作内容</div>
      </div>
      <div class="formMain">
        <div class="orderInfo" style="white-space: pre-wrap">
          {{ $converData.changeLine(detailInfo.position_work_content) }}
        </div>
      </div>
      <div class="stepTitle hasTop">
        <div class="stepName">技能要求</div>
      </div>
      <div class="formMain">
        <div class="orderInfo" style="white-space: pre-wrap">
          {{ $converData.changeLine(detailInfo.skill_requirements) }}
        </div>
      </div>
      <div class="userCont" v-if="detailInfo.enterprise_apply">
        <div class="userImg">
          <img :src="detailInfo.enterprise_apply.enterprise_logo" />
        </div>
        <div class="userInfo">
          <div class="userName">
            <div class="userNameText">
              {{ detailInfo.enterprise_apply.enterprise_name }}
            </div>
            <div class="relTag">已认证</div>
          </div>
          <div class="compName">
            {{ detailInfo.position_city }} ·
            {{ detailInfo.enterprise_apply.enterprise_scale }}
          </div>
        </div>
      </div>
      <div class="notice">
        <div class="tipHead">
          <div class="iconfont icon-sousuo"></div>
          <div>温馨提示</div>
        </div>
        <div class="tipCont">求职过程中请勿缴纳任何费用，请谨慎防止诈骗。</div>
        <div class="tipCont">
          如企业存在虚假、违法、不实等问题，请务必<span class="blueText"
            >联系客服</span
          >处理。
        </div>
      </div>
      <div class="ctrlBtn">
        <div
          class="homeBtn iconfont icon-fanhui1"
          v-if="detailInfo.is_bidder == 1"
          @click="backFn"
        ></div>
        <div class="subBtn" v-if="detailInfo.is_bidder == 1" @click="subFn">
          投递简历
        </div>
        <div class="subBtn" v-if="detailInfo.is_bidder != 1" @click="backFn">
          返回
        </div>
      </div>
    </div>
    <subLoad v-if="showSub"></subLoad>
    <load v-if="!showCont"></load>
    <getTimeOut v-if="showTimeOut"></getTimeOut>
  </div>
</template>
<script>
import { PositionDeliver, PositionDetails } from "@/http/api";
import {
  showSuccessToast,
  showToast,
  showConfirmDialog,
  showDialog,
} from "vant";
import load from "@/components/public/load.vue";
import getTimeOut from "@/components/public/getTimeOut.vue";
import subLoad from "@/components/public/subLoad.vue";
export default {
  components: { subLoad, load, getTimeOut },
  name: "",
  data() {
    return {
      showTimeOut: false,
      showCont: false,
      showSub: false,
      detailInfo: {},
      walfArr: [],
    };
  },
  props: {},
  setup() {},
  methods: {
    backFn() {
      this.$router.back();
    },
    subFn() {
      showConfirmDialog({
        title: "简历投递提醒",
        confirmButtonText: "投递",
        message: "确认投递此岗位吗？",
      })
        .then(() => {
          this.showSub = true;
          let data = {
            enterprise_position_id: this.$route.query.enterprise_position_id,
          };
          PositionDeliver(data)
            .then((res) => {
              if (res.data.code == 1) {
                showSuccessToast("投递成功");
                this.getData();
              } else {
                if (res.data.msg == "请先完善简历") {
                  showConfirmDialog({
                    title: "简历投递失败",
                    confirmButtonText: "去完善",
                    message: "你还没有完善简历，无法投递岗位。",
                  })
                    .then(() => {
                      this.$router.push({ path: "/book" });
                    })
                    .catch(() => {});
                } else if (res.data.msg == "简历状态有误，请检查后再试") {
                  showDialog({
                    title: "简历投递失败",
                    message: "简历状态有误，请检查简历正常后再试",
                  }).then(() => {});
                } else if (res.data.msg == "你的账号已被禁用") {
                  showDialog({
                    title: "操作失败提示",
                    message: "你的账号已被禁用，无法投递简历。",
                  }).then(() => {});
                } else {
                  showToast(res.data.msg);
                }
              }
              this.showSub = false;
            })
            .catch(() => {
              this.showSub = false;
            });
        })
        .catch(() => {});
    },
    getData() {
      let data = {
        enterprise_position_id: this.$route.query.enterprise_position_id,
      };
      PositionDetails(data)
        .then((res) => {
          if (res.data.code == 1) {
            this.walfArr = res.data.data.welfare_treatment.split(",");
            this.detailInfo = res.data.data;
          } else {
            showToast(res.data.msg);
          }
          this.showCont = true;
        })
        .catch(() => {
          this.showTimeOut = true;
          this.showCont = true;
        });
    },
  },
  mounted() {},
  created() {
    this.getData();
    // this.showTimeOut = true;
    // this.showCont = true;
  },
};
</script>

<style scoped lang="less">
.container {
  // padding-bottom: 1.25rem;
  box-sizing: border-box;
  background-color: #fff;
  // padding: 1.75rem 4% 4rem;
  min-height: 100vh;
  overflow: hidden;
  .showCont {
    padding: 1.75rem 4% 4rem;
    box-sizing: border-box;
  }
  .stepTitle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    .sendBook {
      position: absolute;
      right: 0;
      top: 1.5rem;
      z-index: 1;
      img {
        width: 5rem;
        transform: rotate(50deg);
      }
    }
    .stepName {
      font-size: 0.8rem;
      font-weight: bold;
      display: flex;
      align-items: center;
      .quckTag {
        padding: 0.1rem 0.5rem;
        box-sizing: border-box;
        border: 1px solid #ff5757;
        color: #ff5757;
        border-radius: 0.1rem;
        font-size: 0.6rem;
        // margin-left: 0.5rem;
        transform: scale(0.85);
      }
    }

    .moneyNum {
      color: #86a9fb;
      font-size: 0.8rem;
    }
  }
  .tagCont {
    display: flex;
    align-items: center;
    font-size: 0.6rem;
    margin-top: 0.5rem;
    .tagItem {
      color: #666;
    }
    .userNum_ {
      margin: 0 0.25rem;
    }
  }
  .walfCont {
    display: flex;
    margin-top: 0.5rem;
    flex-wrap: wrap;
    .walfItem {
      padding: 0.15rem 0.5rem;
      background-color: #f1f5ff;
      color: #666;
      border-radius: 0.1rem;
      margin-right: 0.5rem;
      margin-bottom: 0.5rem;
      font-size: 0.6rem;
    }
  }
  .hasTop {
    margin-top: 1rem;
  }

  .formMain {
    margin-top: 0.5rem;
    color: #666;

    .orderInfo {
      margin-top: 0.75rem;
    }
  }

  .userCont {
    box-sizing: border-box;
    margin-top: 1rem;
    background-image: linear-gradient(to right bottom, #cbd8f7, #86a9fb);
    color: #fff;
    border-radius: 0.25rem;
    padding: 0.75rem 4%;
    box-sizing: border-box;
    display: flex;
    align-items: center;

    .userImg {
      width: 2.3rem;
      height: 2.3rem;
      border-radius: 50%;
      overflow: hidden;
      padding: 0.1rem;
      box-sizing: border-box;
      background-color: #fff;
      font-size: 0;
      img {
        width: 100%;
      }
    }

    .userInfo {
      flex: 1;
      width: 1rem;
      margin-left: 0.75rem;

      .userName {
        font-weight: bold;
        font-size: 0.7rem;
        display: flex;
        .userNameText {
          max-width: 9rem;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }

        .relTag {
          padding: 0.1rem 0.5rem;
          border: 1px solid #fff;
          color: #fff;
          font-size: 0.6rem;
          font-weight: normal;
          border-radius: 0.1rem;
          transform: scale(0.8);
          position: relative;
          top: -0.1rem;
        }
      }

      .compName {
        font-size: 0.6rem;
        margin-top: 0.25rem;
        color: #fff;
      }
    }
  }

  .notice {
    margin-top: 0.75rem;

    .tipHead {
      width: 100%;
      padding: 0.5rem 0;
      box-sizing: border-box;
      display: flex;
      align-items: center;

      .iconfont {
        margin-right: 0.5rem;
      }
    }

    .tipCont {
      font-size: 0.6rem;
      color: #666;

      .blueText {
        color: #86a9fb;
      }
    }
  }

  .ctrlBtn {
    width: 100%;
    position: fixed;
    left: 0%;
    bottom: 0rem;
    display: flex;
    align-items: center;
    padding: 0.5rem 4%;
    box-sizing: border-box;
    background: #fff;
    .homeBtn {
      width: 2.2rem;
      margin-right: 0.75rem;
      height: 2.2rem;
      line-height: 2.2rem;
      border-radius: 0.25rem;
      background-color: #86a9fb;
      color: white;
      text-align: center;
      font-size: 1rem;
    }
    .subBtn {
      flex: 1;
      line-height: 2.2rem;
      background-color: #86a9fb;
      color: #fff;
      border-radius: 0.25rem;
      text-align: center;
    }
    .saveIcon {
      margin-right: 0.75rem;
      font-size: 1.2rem;
      color: #999;
      // background-color: #86a9fb;
      border: 1px solid #86a9fb;
      line-height: 2.2rem;
      padding: 0 0.6rem;
      border-radius: 0.25rem;
      color: #86a9fb;
      background-color: #fff;
    }
    .isSave {
      background-color: #86a9fb;
      color: #fff;
    }
  }

  .itemForm {
    background-color: #e7eeff;
    padding: 0.75rem;
    box-sizing: border-box;
    overflow: hidden;
    margin-top: 0.75rem;
    border-radius: 0.25rem;
    position: relative;

    .statusImg {
      width: 5rem;
      position: absolute;
      right: 0;
      top: 0rem;

      img {
        width: 100%;
        transform: rotate(50deg);
      }
    }

    .formItem {
      display: flex;
      line-height: 1rem;
      margin-bottom: 0.25rem;

      .itemName {
        margin-right: 0.75rem;
        width: 3rem;
        color: #666;
      }

      .itemVal {
        flex: 1;
        width: 1rem;
        word-break: break-all;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        /* 超出几行省略 */
      }
    }
  }

  .filterMain {
    width: 100%;
    padding: 1.25rem 4%;
    box-sizing: border-box;
    text-align: center;

    .filterName {
      font-size: 1rem;
      font-weight: bold;
    }

    .filterVal {
      margin: 0.75rem 0;

      div {
        margin-bottom: 0.25rem;
      }

      .redText {
        color: #86a9fb;
      }
    }

    .maskBtn {
      width: 100%;
      background-color: #86a9fb;
      color: #fff;
      text-align: center;
      padding: 0.55rem 0;
      margin-top: 1.25rem;
      border-radius: 1.5rem;
    }
  }
}
</style>
